package com.itestor.iptv.modules.common.actions;

import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import com.itestor.iptv.global.actions.AbstractPagedQueryAction;
import com.itestor.iptv.global.bean.AbstractPagedQuery;
import com.itestor.iptv.global.utils.LoggerUtils;
import com.itestor.iptv.modules.common.bean.GroupManageQuery;
import com.itestor.iptv.modules.common.service.GroupManageService;
import com.itestor.iptv.modules.common.service.UserService;
import com.itestor.iptv.modules.common.utils.CommonConstant;
import com.itestor.iptv.modules.common.vo.UserQuery;

/**
 * 
 * @author Mr.li
 * 
 */
public class GroupManageQueryAction extends AbstractPagedQueryAction {

    /**
     * Logger for this class.
     */
    private static final Logger logger = Logger
            .getLogger(GroupManageQueryAction.class);

    private GroupManageService groupManageService;

    @SuppressWarnings("unchecked")
    @Override   
    public AbstractPagedQuery doPagedQuery(ActionForm form,
            HttpServletRequest request, int pagerCount, int pagerOffset)
            throws Exception {
        String groupName = request.getParameter("groupName");
        
        LoggerUtils.logActionInfo("Query the GroupManage"
                + (StringUtils.isEmpty(groupName) ? (" - groupName:" + groupName)
                        : "") + ".", logger, request);

        GroupManageQuery groupManageQuery = new GroupManageQuery();
        groupManageQuery.setPagerCount(pagerCount);
        groupManageQuery.setPagerOffset(pagerOffset);
        
        if (!StringUtils.isEmpty(groupName)) {
            groupManageQuery.setGroupName(groupName);
        }
        
        groupManageService.queryGroupManageList(groupManageQuery);
        
        request.setAttribute(CommonConstant.REQUEST_ATTR_Q_GROUP, groupManageQuery);
        
        return groupManageQuery;
    }

    public void setGroupManageService(GroupManageService pGroupManageService) {
        groupManageService = pGroupManageService;
    }

}